package cn.icatw.gulimall.member.web;

import cn.icatw.common.utils.R;
import cn.icatw.gulimall.member.feign.OrderFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

/**
 * 成员网络控制器
 *
 * @author icatw
 * @date 2022/3/30
 * @email 762188827@qq.com
 * @apiNote
 */
@Controller
@Slf4j
public class MemberWebController {
    @Autowired
    OrderFeignService orderFeignService;

    @GetMapping("/memberOrder.html")
    public String memberOrderPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, Model model) {
        //获取到支付宝给我们传来的所有请求数据
        //查出当前登陆登用户所有订单列表数据
        Map<String, Object> params = new HashMap<>();
        params.put("page", pageNum.toString());
        R r = orderFeignService.listWithItem(params);
        //log.info(JSON.toJSONString(r));
        //TODO 分页的总记录数和总页码需要配置mybatis分页插件
        model.addAttribute("orders", r);
        //log.info(JSON.toJSONString(r.get("page")));
        return "orderList";
    }
}
